# _*_ coding:utf-8 _*_

import re
import urllib2
from bs4 import BeautifulSoup
import json

url = r'http://baidu.lecai.com/lottery/ajax_get_stats_omit.php?lottery_type=50&play_type=5002'


# 获取url内容
def getResponseContent(url):
    try:

        # 'Cache-Control: max-age=0, no-cache',
        # 'Pragma: no-cache'

        req = urllib2.Request(url.encode("utf8"))
        req.add_header('Referer', 'http://baidu.lecai.com/lottery/ssq/')
        req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0')
        req.add_header('Accept', 'application/json, text/javascript, */*; q=0.01')
        response = urllib2.urlopen(req)
        # response = urllib2.urlopen(url.encode("utf8"))
        ss = ''
    except Exception, e:
        print e
    else:
        # self.log.info(u'Python 返回URL:%s 数据成功' % url)
        return response.read()


def getCold():
    item = []
    import sys
    default_encoding = 'utf-8'
    if sys.getdefaultencoding() != default_encoding:
        reload(sys)
        sys.setdefaultencoding(default_encoding)
    ss = getResponseContent(url)
    content = json.loads(ss)
    jomitred = content['data']['group'][0]['numbers']
    jomitblue = content['data']['group'][1]['numbers']
    jr =[]

    for i in xrange(33):
        jr.append(jomitred['%02d' % (i+1)]['appear_recently'])

    temp =[]
    nmin = min(jr)
    num = -1

    try:
        while 1:
            num = jr.index(nmin, num+1)
            if num:
                temp.append(num+1)
    except:
        return temp




if __name__ == '__main__':
    Get = getCold()
    print Get
